#include "cgzCLua.h"
#include "cgzCTimer.h"
#include "cgzCThreadPool.h"

extern "C" const char *__asan_default_options()
{
    return "log_path=./asan_log";
}

int main(int argc, char *argv[])
{
    const char *argThread = argv[1];
    const char *argLuaMain = argv[2];
    const char *argLuaMode = argv[3];
    const char *argServerId = argv[4];
    int threadNum = atoi(argThread);
    if (threadNum < 1 || argc < 4)
    {
        std::cout << "Invalid thread number" << std::endl;
        return 0;
    }
    intiCore();
    // 线程池
    cgzCThreadPool *pTPool = cgzCThreadPool::Instance(threadNum);
    // 定时器
    cgzCTimer cgzTimer(pTPool, "cgzCTimer");
    pTPool->addTask(cgzTimer.getName(), &cgzTimer);
    // lua虚拟机

    cgzCLua cgzlua(pTPool, "cgzCLua", argLuaMode, argServerId);
    cgzlua.setBusy();
    pTPool->addTask(cgzlua.getName(), &cgzlua);
    cgzlua.setFree();
    cgzlua.reload(argLuaMain);
    lookMems();
    pTPool->start();
    pTPool->waits();
    lookMems();
    return 0;
}
